package com.dems.web;

import com.dems.dao.AdministratorDao;
import com.dems.dao.StudentDao;
import com.dems.domain.Administrator;
import com.dems.domain.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/UpdateAdminServlet")
public class UpdateAdminServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private StudentDao registStudentDao = new StudentDao();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateAdminServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取参数
        String administratorNum = request.getParameter("administratorNum");
        String administratorName = request.getParameter("administratorName");
        String administratorPassword = request.getParameter("administratorPassword");
        String buildingId = request.getParameter("buildingId");
        String administratorPhone = request.getParameter("administratorPhone");
        //设置administrator
        Administrator administrator = new Administrator();
        administrator.setAdministratorNum(administratorNum);
        administrator.setAdministratorName(administratorName);
        administrator.setAdministratorPassword(administratorPassword);
        administrator.setBuildingId(buildingId);
        administrator.setAdministratorPhone(administratorPhone);

        AdministratorDao ad = new AdministratorDao();
        ad.update(administrator);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}
